import random
from threading import Thread
from time import sleep


def task1(task_name):
    sleep(random.random())
    print("执行{}".format(task_name))


def task2(task_name):
    sleep(random.random())
    print("执行{}".format(task_name))


if __name__ == '__main__':
    t1 = Thread(target=task1, name="线程1", args=("任务1",))
    t2 = Thread(target=task2, name="线程2", args=("任务2",))

    t1.start()
    t2.start()
